x=str(input())
a=[]
for i in x:
    a.append(i)
if ("(" in a and ")" not in a) or ("{" in a and "}" not in a) or (("[" in a and "]" not in a)):
    print("False")
elif (a.index("(")+1==a.index("}")) or (a.index("(")+1==a.index("]")) or (a.index("[")+1==a.index(")")) or (a.index("[")+1==a.index("}")) or (a.index("{")+1==a.index("]")) or (a.index("{")+1==a.index(")")):
    print("False")
else:
    print("True")
